﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Gun : MonoBehaviour {

	public WeaponPool gatlinPool;
	public WeaponPool cannonPool;
	public WeaponPool missilePool;
	public WeaponPool laserPool;
	public WeaponPool jumppingMissilePool;
	public WeaponPool assaultMissilePool;
	public WeaponPool cruiseMissilePool;
	public WeaponPool burningMissilePool;
	public WeaponPool shipTorpedoPool;
	public WeaponPool cruiseAssaultMissilePool;
	// public GameObject gatlin;//加特林
	// public GameObject cannon;//加农炮
	// public GameObject missile;//导弹

	public GameObject laser;//激光
	public GameObject interlockLaser;//连锁激光炮
	public GameObject pulseLaser;//脉冲激光炮
	public GameObject absorptionLaser;//吸收激光炮
	public GameObject chargedParticleGun;//荷电粒子炮
	public GameObject stagnationChargedParticleGun;//停滞电荷粒子炮

	public GameObject shield;//护盾
	public GameObject recoveryDevice;//恢复装置
	public GameObject cloakDevice;//隐身装置
	public GameObject propelDevice;//推进装置
	public GameObject transferDevice;//推进装置


	public GameObject target;//攻击目标
	protected WeaponInfo weaponInfo;//武器数据信息
	protected float startTime = 0;//延时调用
	protected float angle = 0;//子弹角度
	protected bool trigger = true;

	public bool isShow = false;
	public bool isInLaserAttackDist = false;
	public float timer = 0;

	private GameObject tempTarget=null;



	public void SetTarget(GameObject target){
		this.target = target;
	}

	public WeaponInfo GetWeaponInfo()
	{
		return this.weaponInfo;
	}


	public void StopFire(){
//		CancelInvoke("Gatlin");
//		CancelInvoke("Cannon");
//		CancelInvoke("Missile");
//		CancelInvoke("Laser");
//		CancelInvoke ("JumpingMissile");
//		CancelInvoke ("AssaultMissile");
//		CancelInvoke ("SplitAssaultMissile");
		CancelInvoke();
	}

	public void OpenFire(WeaponInfo weaponInfo){
		this.weaponInfo = weaponInfo;
		if (weaponInfo.IsReady == true) 
		{
			weaponInfo.IsReady = false;
		} else 
		{
			return;
		}
		// weaponInfo.ShowSelf();
		string name = weaponInfo.Name.ToString();

		switch(name){
			case "Gatlin":
				InvokeRepeating("Gatlin", startTime, weaponInfo.AttackRateTime);
				break;
			case "Cannon":
				InvokeRepeating("Cannon", startTime, weaponInfo.AttackRateTime);
				break;	
			case "Missile":
				InvokeRepeating("Missile", startTime, weaponInfo.AttackRateTime);
				break;
			case "Laser":
				InvokeRepeating("Laser", startTime, 0.01f);
				break;
			case "Shield":
				InvokeRepeating("Shield", startTime, 0.01f);
				break;
			case "RecoveryDevice":
				RecoveryDevice();
				break;
			case "CloakDevice":
				CloakDevice();
				break;
			case "PropelDevice":
				PropelDevice();
				break;
			case "TransferDevice":
				TransferDevice();
				break;
			case "DiffusionGatlin":
				InvokeRepeating ("DiffusionGatlin", startTime, weaponInfo.AttackRateTime);
				break;
			case "JumpingMissile":
				InvokeRepeating ("JumpingMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case"JumppingAssaultMissile":
				InvokeRepeating ("JumppingAssaultMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "SplitJumpingMissile":
				InvokeRepeating ("SplitJumpingMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "AssaultMissile":
				InvokeRepeating ("AssaultMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "SplitAssaultMissile":
				InvokeRepeating ("SplitAssaultMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "CruiseMissile":
				InvokeRepeating ("CruiseMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "SplitCruiseMissile":
				InvokeRepeating ("SplitCruiseMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "BurningMissile":
				InvokeRepeating ("BurningMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "SplitBurningMissile":
				InvokeRepeating ("SplitBurningMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "ShipTorpedoPool":
				InvokeRepeating ("ShipTorpedoPool", startTime, weaponInfo.AttackRateTime);
				break;
			case "ShipTorpedo":
				InvokeRepeating ("ShipTorpedo", startTime, weaponInfo.AttackRateTime);
				break;
			case "SplitShipTorpedo":
				InvokeRepeating ("SplitShipTorpedo", startTime, weaponInfo.AttackRateTime);
				break;
			case "JumpingShipTorpedo":
				InvokeRepeating ("JumpingShipTorpedo", startTime, weaponInfo.AttackRateTime);
				break;
			case "CruiseAssaultMissile":
				InvokeRepeating ("CruiseAssaultMissile", startTime, weaponInfo.AttackRateTime);
				break;
			case "InterlockLaser":
				InvokeRepeating ("InterlockLaser", startTime, 0.01f);
				break;
			case "PulseLaser":
				InvokeRepeating ("PulseLaser", startTime, 0.01f);
				break;
			case "AbsorptionLaser":
				InvokeRepeating ("AbsorptionLaser", startTime, 0.01f);
				break;
			case "InterlockPulseLaser":
				InvokeRepeating ("InterlockPulseLaser", startTime, 0.01f);
				break;
			case "ChargedParticleGun":
				InvokeRepeating ("ChargedParticleGun", startTime, 0.01f);
				break;
			case "StagnationChargedParticleGun":
				InvokeRepeating ("StagnationChargedParticleGun", startTime, 0.01f);
				break;
			case "ThroughChargedParticleGun":
				InvokeRepeating ("ThroughChargedParticleGun", startTime, 0.01f);
				break;
		}
	}

	void Gatlin()
	{
//		print("Gatlin");	
		if(target != null)
		{
			this.transform.up = (target.transform.position - this.transform.position).normalized;
			GameObject gameObj = gatlinPool.New();
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			gameObj.GetComponent<Gatlin>().SetWeaponInfo(weaponInfo);
			gameObj.GetComponent<Gatlin>().trigger = trigger;
			gameObj.GetComponent<Gatlin>().isAttack = true;
			gameObj.GetComponent<Gatlin>().isInPool = false;
		}
	}

	void Cannon()
	{
			this.transform.up = (target.transform.position - this.transform.position).normalized;
			GameObject gameObj = cannonPool.New();
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;

			gameObj.GetComponent<Cannon>().SetWeaponInfo(weaponInfo);
			gameObj.GetComponent<Cannon>().trigger = trigger;
			gameObj.GetComponent<Cannon>().isAttack = true;
			gameObj.GetComponent<Cannon>().isInPool = false;
	}

	#region Missile 导弹部分

	/// <summary>
	/// 设置导弹的通用属性
	/// </summary>
	/// <param name="gameObj">Game object.</param>
	public void MissileSet(GameObject gameObj,bool isFast){
		gameObj.GetComponent<Missile>().SetTarget(target);
		gameObj.GetComponent<Missile>().SetWeaponInfo(weaponInfo);
		gameObj.GetComponent<Missile>().trigger = trigger;
		gameObj.GetComponent<Missile>().isAttack = true;
		gameObj.GetComponent<Missile>().isInPool = false;
		gameObj.GetComponent<Missile> ().isFast = isFast;
	}
	/// <summary>
	/// 导弹跳跃
	/// </summary>
	/// <param name="go">Go.</param>
	/// <param name="targetTran">Target tran.</param>
	IEnumerator Jumping(GameObject go ,Transform targetTran,bool hasAfterburner=false)
	{
		yield return new WaitForSeconds (1.0f);
		if(hasAfterburner)
		{
			go.GetComponent<AssaultMissile> ().Afterburner.GetComponent<Afterburner> ().Stop ();
			yield return new WaitForSeconds(0.1f);
			JumpEffect ();
			go.transform.position = new Vector3 (1000,1000,0);
		}
		if (go.GetComponent<Missile> ().isAttack == true) 
		{
			Vector2 rand = Random.insideUnitCircle;
			if (targetTran != null) {
				yield return new WaitForSeconds (0.5f);
				if (hasAfterburner) {
					go.GetComponent<AssaultMissile> ().Afterburner.GetComponent<Afterburner> ().Play ();
				}
				go.transform.position = targetTran.position + new Vector3 (rand.x * 5, rand.y * 5, 0);
			}
		}
	}
	/// <summary>
	/// 导弹分裂
	/// </summary>
	/// <returns>The split.</returns>
	/// <param name="missile">导弹对象</param>
	/// <param name="pool">对应的对象池</param>
	/// <param name="count">分裂数量</param>
	/// <param name="time">多少秒后分裂</param>
	/// <param name="rotateZ">每个导弹分裂后旋转的角度</param>  （不要重叠）
	/// <param name="isJumpping">分裂后是否需要跳跃</param>
	/// <param name="hasAfterburner">是否拥有拖尾效果</param> (需要挂拖尾脚本-->Afterburner)
	/// <param name="isFast">速度是否为快速的导弹</param> （不为快速的导弹，一开始是以当前方向先飞一段时间，再追踪敌人,反之快速导弹则实例化出来就追踪敌人）
	IEnumerator IESplit(GameObject missile,WeaponPool pool,int count,float time,float[] rotateZ,bool isJumpping,bool hasAfterburner,bool isFast)
	{
		yield return new WaitForSeconds (time);
		for (int i = 0; i < count; i++) 
		{
			GameObject gameObj = pool.New ();
			if (missile != null) {
				gameObj.transform.position = missile.transform.position;
				gameObj.transform.rotation = Quaternion.AngleAxis (transform.rotation.eulerAngles.z+rotateZ[i],Vector3.forward);
				MissileSet (gameObj,isFast);
				if (target != null) {
					if (isJumpping) {
						StartCoroutine (Jumping (gameObj, target.transform));
					}
				}
				if (hasAfterburner) 
				{
					gameObj.GetComponent<AssaultMissile> ().Afterburner.GetComponent<Afterburner> ().Play ();
				}
			}
		}
	}
	/// <summary>
	/// 跳跃特效
	/// </summary>
	void JumpEffect()
	{
		
	}
	/// <summary>
	/// 导弹
	/// </summary>
	void Missile()
	{
		// this.transform.up = (target.transform.position - this.transform.position).normalized;
		GameObject gameObj = missilePool.New();
		gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
		gameObj.transform.rotation = transform.rotation;
		MissileSet (gameObj,true);
	}
	/// <summary>
	/// 跳跃导弹
	/// </summary>
	/// <returns>The missile.</returns>
	GameObject JumpingMissile()
	{
		if (target != null) {
			GameObject gameObj = jumppingMissilePool.New ();

			gameObj.transform.position = new Vector3 (transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			MissileSet (gameObj,false);
			StartCoroutine (Jumping (gameObj, target.transform));
			return gameObj;
		} 
		return null;
	}
	/// <summary>
	/// 分裂跳跃导弹
	/// </summary>
	void SplitJumpingMissile()
	{
		GameObject missile =  JumpingMissile ();
		StartCoroutine(IESplit(missile,jumppingMissilePool,1,0.4f,new float[]{90},true,false,false));
	}
		
	/// <summary>
	/// 突击导弹
	/// </summary>
	/// <returns>The missile.</returns>
	GameObject AssaultMissile()
	{
		if (target != null) {
			GameObject gameObj = assaultMissilePool.New ();
			gameObj.transform.position = new Vector3 (transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			MissileSet (gameObj,true);
			gameObj.GetComponent<AssaultMissile> ().Afterburner.GetComponent<Afterburner> ().Play();
			return gameObj;
		}
		return null;
	}
	/// <summary>
	/// 分裂突击导弹,暂定分裂2个
	/// </summary>
	void SplitAssaultMissile()
	{
		GameObject missile =  AssaultMissile ();
		StartCoroutine(IESplit(missile,assaultMissilePool,2,0.2f,new float[]{45,-45},false,true,true));
	}
	/// <summary>
	/// 跳跃突击导弹
	/// </summary>
	void JumppingAssaultMissile()
	{
		GameObject missile =  AssaultMissile ();
		StartCoroutine (Jumping (missile, target.transform,true));
	}

	/// <summary>
	/// 巡舰导弹
	/// </summary>
	/// <returns>The missile.</returns>
	GameObject CruiseMissile()
	{
		if (target != null) {
			GameObject gameObj = cruiseMissilePool.New ();

			gameObj.transform.position = new Vector3 (transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			MissileSet (gameObj,false);
			return gameObj;
		} 
		return null;
	}
	/// <summary>
	/// 分裂巡舰导弹
	/// </summary>
	void SplitCruiseMissile()
	{
		GameObject misslie = CruiseMissile ();
		StartCoroutine(IESplit(misslie,cruiseMissilePool,1,0.4f,new float[90],false,false,false));
	}
	/// <summary>
	/// 巡航突击导弹
	/// </summary>
	GameObject CruiseAssaultMissile()
	{
		if (target != null) {
			GameObject gameObj = cruiseAssaultMissilePool.New ();
			gameObj.transform.position = new Vector3 (transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			MissileSet (gameObj,true);
			gameObj.GetComponent<CruiseAssaultMissile> ().Afterburner.GetComponent<Afterburner> ().Play();
			return gameObj;
		}
		return null;
	}

	/// <summary>
	/// 燃烧导弹
	/// </summary>
	GameObject BurningMissile()
	{
		if (target != null) {
			GameObject gameObj = burningMissilePool.New ();

			gameObj.transform.position = new Vector3 (transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			MissileSet (gameObj,false);
			return gameObj;
		} 
		return null;
	}
	/// <summary>
	/// 分裂燃烧导弹
	/// </summary>
	void SplitBurningMissile()
	{
		GameObject misslie = BurningMissile ();
		StartCoroutine(IESplit(misslie,burningMissilePool,1,0.4f,new float[90],false,false,false));
	}

	/// <summary>
	/// 对舰鱼雷
	/// </summary>
	/// <returns>The torpedo pool.</returns>
	GameObject ShipTorpedo()
	{
		if (target != null) {
			GameObject gameObj = shipTorpedoPool.New ();
			gameObj.transform.position = new Vector3 (transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			MissileSet (gameObj,false);
			return gameObj;
		} 
		return null;
	}
		
	/// <summary>
	/// 跳跃对舰鱼雷
	/// </summary>
	/// <returns>The ship torpedo.</returns>
	GameObject JumpingShipTorpedo()
	{
		if (target != null) {
			GameObject gameObj = shipTorpedoPool.New ();
	
			gameObj.transform.position = new Vector3 (transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			MissileSet (gameObj,false);
			StartCoroutine (Jumping (gameObj, target.transform));
			return gameObj;
		} 
		return null;
	}
		
	/// <summary>
	/// 分裂对舰鱼雷
	/// </summary>
	void SplitShipTorpedo()
	{
		GameObject misslie = ShipTorpedo ();
		StartCoroutine(IESplit(misslie,shipTorpedoPool,1,0.4f,new float[90],false,false,false));
	}
		
	#endregion


	#region Laser 激光炮部分

	/// <summary>
	/// 激光炮的基础设置
	/// </summary>
	/// <param name="gameObj">Game object.</param>
	void LaserBaseSet(GameObject gameObj,int especialId=0){
		gameObj.GetComponent<Laser> ().especialEffectId = weaponInfo.SpecOne;
		gameObj.GetComponent<Laser>().SetTarget(target);
		gameObj.GetComponent<Laser>().SetWeaponInfo(weaponInfo);
		gameObj.GetComponent<Laser>().trigger = trigger;
		gameObj.GetComponent<Laser>().isAttack = true;
		gameObj.GetComponent<Laser>().isInPool = false;
		gameObj.transform.SetParent(this.transform);
	}

	/// <summary>
	/// 激光
	/// </summary>
	void Laser()
	{
		if(timer >= weaponInfo.AttackRateTime)
		{
			timer = 0;
			GameObject gameObj = GameObject.Instantiate(laser);
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			LaserBaseSet(gameObj);
		}
	}

	/// <summary>
	/// 连锁激光炮
	/// </summary>
	void InterlockLaser()
	{
		if(timer >= weaponInfo.AttackRateTime)
		{
			timer = 0;
			GameObject gameObj = GameObject.Instantiate(interlockLaser);
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			LaserBaseSet(gameObj);
		}
	}
	/// <summary>
	/// 脉冲激光炮
	/// </summary>
	void PulseLaser()
	{
		if(timer >= weaponInfo.AttackRateTime)
		{
			timer = 0;
			GameObject gameObj = GameObject.Instantiate(pulseLaser);
			gameObj.AddComponent<Laser> ();
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			LaserBaseSet(gameObj);
		}
	}
	/// <summary>
	/// 连锁脉冲激光炮
	/// </summary>
	void InterlockPulseLaser()
	{
		if(timer >= weaponInfo.AttackRateTime)
		{
			timer = 0;
			GameObject gameObj = GameObject.Instantiate(pulseLaser);
			gameObj.AddComponent<InterlockLaser> ();
			gameObj.GetComponent<InterlockLaser> ().laser = laser;
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			LaserBaseSet(gameObj);
		}
	}
	/// <summary>
	/// 吸收激光炮
	/// </summary>
	void AbsorptionLaser()
	{
		if(timer >= weaponInfo.AttackRateTime)
		{
			timer = 0;
			GameObject gameObj = GameObject.Instantiate(absorptionLaser);
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			LaserBaseSet(gameObj);
		}
	}
	/// <summary>
	/// 电荷粒子炮
	/// </summary>
	void ChargedParticleGun()
	{
		if(timer >= weaponInfo.AttackRateTime)
		{
			timer = 0;
			GameObject gameObj = GameObject.Instantiate(chargedParticleGun);
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			LaserBaseSet(gameObj);
		}
	}
	/// <summary>
	/// 停滞电荷粒子炮
	/// </summary>
	void StagnationChargedParticleGun()
	{
		if (timer >= weaponInfo.AttackRateTime) {
			timer = 0;
			tempTarget = target;
			GameObject gameObj = GameObject.Instantiate (chargedParticleGun);
			gameObj.transform.position = new Vector3 (transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			LaserBaseSet (gameObj);
		}else if(timer>weaponInfo.DurationTime)
		{
			EspecialEffect.GetInstance ().Stagnation (tempTarget,5);
		}
	}
	/// <summary>
	/// 穿透电荷粒子炮
	/// </summary>
	void ThroughChargedParticleGun()
	{
		if(timer >= weaponInfo.AttackRateTime)
		{
			timer = 0;
			GameObject gameObj = GameObject.Instantiate(chargedParticleGun);
			gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj.transform.rotation = transform.rotation;
			LaserBaseSet(gameObj);
		}
	}
		
	#endregion

	void Shield()
	{
		if(timer >= weaponInfo.AttackRateTime)
		{
			timer = 0;
			GameObject gameObj = GameObject.Instantiate(shield);
			gameObj.transform.position = new Vector3(target.transform.position.x, target.transform.position.y, target.transform.position.z);
			gameObj.transform.rotation = transform.rotation;
			gameObj.GetComponent<Shield>().SetGun(gameObject);
			gameObj.GetComponent<Shield>().SetTarget(target);
			gameObj.GetComponent<Shield>().SetWeaponInfo(weaponInfo);
			gameObj.GetComponent<Shield>().trigger = trigger;
			gameObj.GetComponent<Shield>().isDefend = true;
			target.GetComponent<ShieldManager>().AddShield(gameObj);
		}
	}

	void RecoveryDevice()
	{
		GameObject gameObj = GameObject.Instantiate(recoveryDevice);
		gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
		gameObj.transform.rotation = transform.rotation;
		gameObj.GetComponent<RecoveryDevice>().SetTarget(target);
		gameObj.GetComponent<RecoveryDevice>().SetWeaponInfo(weaponInfo);
		gameObj.GetComponent<RecoveryDevice>().trigger = trigger;
		gameObj.transform.SetParent(target.transform);
	}

	void CloakDevice()
	{
		GameObject gameObj = GameObject.Instantiate(cloakDevice);
		gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
		gameObj.transform.rotation = transform.rotation;
		gameObj.GetComponent<CloakDevice>().SetGun(this.gameObject);		
		gameObj.GetComponent<CloakDevice>().SetTarget(target);
		gameObj.GetComponent<CloakDevice>().SetWeaponInfo(weaponInfo);
		gameObj.GetComponent<CloakDevice>().trigger = trigger;
		gameObj.transform.SetParent(target.transform);
	}

	
	void PropelDevice()
	{
		GameObject gameObj = GameObject.Instantiate(propelDevice);
		gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
		gameObj.transform.rotation = transform.rotation;
		gameObj.GetComponent<PropelDevice>().SetGun(this.gameObject);				
		gameObj.GetComponent<PropelDevice>().SetTarget(target);
		gameObj.GetComponent<PropelDevice>().SetWeaponInfo(weaponInfo);
		gameObj.GetComponent<PropelDevice>().trigger = trigger;
		gameObj.transform.SetParent(target.transform);
	}


	void TransferDevice()
	{
		GameObject gameObj = GameObject.Instantiate(transferDevice);
		gameObj.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
		gameObj.transform.rotation = transform.rotation;
		gameObj.GetComponent<TransferDevice>().SetGun(this.gameObject);				
		gameObj.GetComponent<TransferDevice>().SetTarget(target);
		gameObj.GetComponent<TransferDevice>().SetWeaponInfo(weaponInfo);
		gameObj.GetComponent<TransferDevice>().trigger = trigger;
		gameObj.transform.SetParent(target.transform);
	}

	void DiffusionGatlin()
	{
		if(weaponInfo.SpecOne == 1)
		{
			this.transform.up = (target.transform.position - this.transform.position).normalized;
			GameObject gameObj1 = gatlinPool.New();
			gameObj1.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj1.transform.rotation = transform.rotation;
			gameObj1.GetComponent<Gatlin>().SetWeaponInfo(weaponInfo);
			gameObj1.GetComponent<Gatlin>().trigger = trigger;
			gameObj1.GetComponent<Gatlin>().isAttack = true;
			gameObj1.GetComponent<Gatlin>().isInPool = false;

			// this.transform.up = (target.transform.position - this.transform.position).normalized;
			GameObject gameObj2 = gatlinPool.New();
			gameObj2.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj2.transform.rotation = Quaternion.AngleAxis(6, new Vector3(0,0,1)) * transform.rotation;
			gameObj2.GetComponent<Gatlin>().SetWeaponInfo(weaponInfo);
			gameObj2.GetComponent<Gatlin>().trigger = trigger;
			gameObj2.GetComponent<Gatlin>().isAttack = true;
			gameObj2.GetComponent<Gatlin>().isInPool = false;
		
			// this.transform.up = (target.transform.position - this.transform.position).normalized;
			GameObject gameObj3 = gatlinPool.New();
			gameObj3.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
			gameObj3.transform.rotation = Quaternion.AngleAxis(-6, new Vector3(0,0,1)) * transform.rotation;
			gameObj3.GetComponent<Gatlin>().SetWeaponInfo(weaponInfo);
			gameObj3.GetComponent<Gatlin>().trigger = trigger;
			gameObj3.GetComponent<Gatlin>().isAttack = true;
			gameObj3.GetComponent<Gatlin>().isInPool = false;
		}
	}


}
